FROM {{ namespace }}/{{ infra_image_prefix }}base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block kibana_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{{ macros.enable_extra_repos(['kibana']) }}

{{ macros.configure_user(name='kibana') }}

# NOTE(hrw): upstream package ships x86_64 binaries for NodeJS. On other
# architectures we install NodeJS from distro and remove binaries.

{% if base_arch != 'x86_64' and base_distro in ['debian'] %}

RUN dpkg --add-architecture amd64 && \
{{ macros.install_packages(['nodejs', 'kibana-oss:amd64'], chain=True) }} \
&& rm -rf /usr/share/kibana/node

{% else %}

{% set kibana_packages = ['kibana-oss'] %}

{{ macros.install_packages(kibana_packages | customizable("packages")) }}

{% endif %}

COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN chmod 755 /usr/local/bin/kolla_extend_start

{% block kibana_footer %}{% endblock %}
{% block footer %}{% endblock %}

USER kibana
